home *** CD-ROM | disk | FTP | other *** search
- (*$C-,V-,U-,R-,K-*)
- PROGRAM PibTerm;
-
- (*----------------------------------------------------------------------*)
- (* PibTerm --- Terminal Emulator in Turbo Pascal *)
- (*----------------------------------------------------------------------*)
- (* *)
- (* Author: (c) 1985 by Philip R. Burns *)
- (* *)
- (* Date: November, 1985 *)
- (* Version: 1.0 (January, 1985) *)
- (* 2.0 (July, 1985) *)
- (* 3.0 (October, 1985) *)
- (* 3.2 (November, 1985) *)
- (* *)
- (* Systems: For MS-DOS on IBM PCs and close compatibles only. *)
- (* Note: I have checked these on Zenith 151s under *)
- (* MSDOS 2.1 and IBM PCs under PCDOS 2.0. *)
- (* *)
- (* I have also successfully run PibTerm under *)
- (* SoftLogic's DoubleDos. *)
- (* *)
- (* Overview: This program provides a comprehensive terminal emulation *)
- (* and remote communications facility. PibTerm emulates *)
- (* five different types of terminals: *)
- (* *)
- (* (1) Dec VT52 *)
- (* (2) Dec VT100 (ANSI) *)
- (* (3) BBS ANSI (DEC private codes not interpreted) *)
- (* (4) Dumb "glass" TTY *)
- (* (5) Split-screen dumb-terminal mode *)
- (* *)
- (* PibTerm allows for file transfer facilities using *)
- (* several different protocols: *)
- (* *)
- (* (1) Ascii capture *)
- (* (2) Xmodem checksum and CRC *)
- (* (3) Modem7 *)
- (* (4) Telink *)
- (* (5) Ymodem *)
- (* (6) Kermit *)
- (* (7) CompuServe B *)
- (* *)
- (* The commands and general program use follow that of the *)
- (* popular PC-TALK and QMODEM programs. *)
- (* *)
- (* PibTerm also provides a simple host communications *)
- (* facility like a mini-BBS. *)
- (* *)
- (*----------------------------------------------------------------------*)
- (* *)
- (* Restriction *)
- (* ----------- *)
- (* *)
- (* You may use this code only for NON COMMERCIAL purposes *)
- (* unless you explicitly obtain my permission. I take a dim *)
- (* view of others making money on my work and those of other *)
- (* people whose code I've inserted here. *)
- (* *)
- (* Please feel free to add new features. I wrote this *)
- (* program to give people a useful and usable basic terminal *)
- (* facility, and to show how Turbo Pascal can be used for *)
- (* asynchronous communications, menu display, windowing, and *)
- (* so on. I hope that you find this program useful -- and, *)
- (* if you expand upon it, please upload your extensions so *)
- (* that all of us can enjoy them! *)
- (* *)
- (*----------------------------------------------------------------------*)
- (* *)
- (* Suggestions for improvements or corrections are welcome. *)
- (* Please leave messages on Gene Plantz's BBS (312) 882 4145 *)
- (* or Ron Fox's BBS (312) 940 6496. *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- (*$IGLOBTYPE.PAS *)
- (*$IASCII.PAS *)
-
- (*----------------------------------------------------------------------*)
- (* GLOBAL VARIABLE DEFINITIONS *)
- (*----------------------------------------------------------------------*)
-
- CONST
- Pibterm_Version = '3.2.5 (November, 1985)' (* Version no. of PibTerm *);
- Max_Screen_Col = 80 (* PC's screen width *);
-
- (*----------------------------------------------------------------------*)
- (* PibTerm Command Types *)
- (*----------------------------------------------------------------------*)
-
- CONST
- No_Of_PibTerm_Commands = 58;
- No_Of_Pibterm_Commands_Minus_One = 57;
-
- TYPE
- PibTerm_Command_Type = ( AddLFSy, AreaCodeSy, BreakSy, CaptureSy,
- CaseSy,
- ClearSy, DelaySy, DialSy, DosSy,
- EchoSy, EditSy, ElseSy, EndCaseSy,
- EndIfSy, EndWhileSy, ExitSy, FastCSy,
- FileSy, GossipSy, GoToSy, HangUpSy,
- HostSy, IfConSy, IfFoundSy, IfLocStrSy,
- IfRemStrSy, InfoSy, InputSy, KeyDefSy,
- KeySendSy, KeySy, LabelSy, LogSy,
- MessageSy, MuteSy, OtherSy, ParamSy,
- QuitSy,
- ReceiveSy, ReDialSy, RepeatSy, ResetSy,
- RInputSy, SDumpSy, SendSy, STextSy,
- SuspendSy, TextSy,
- TimersSy, TranslateSy, UntilSy, ViewSy,
- WaitSy, WaitStrSy, WhenSy, WhileSy,
- Bad_Command, Null_Command
- );
-
- (* Command to be executed *)
- VAR
- PibTerm_Command : PibTerm_Command_Type;
-
- (* Conversion table from input to *)
- (* commands. *)
- VAR
- PibTerm_Command_Table : ARRAY[0..255] OF PibTerm_Command_Type;
-
-
- (*----------------------------------------------------------------------*)
- (* Timing constants *)
- (*----------------------------------------------------------------------*)
-
- CONST
- One_Second_Delay = 1000 (* Delay argument for 1 second delay *);
- Two_Second_Delay = 2000 (* Delay argument for 2 second delay *);
- Three_Second_Delay = 3000 (* Delay argument for 3 second delay *);
- Tenth_of_a_second_Delay = 100 (* 1/10 second delay *);
-
- VAR
- Delay_Time : INTEGER; (* Time to delay in response to DELAY *)
- (* command *)
-
- (*----------------------------------------------------------------------*)
- (* Text/Menu Colors *)
- (*----------------------------------------------------------------------*)
-
- VAR
- ForeGround_Color : INTEGER (* Color for ordinary text *);
- BackGround_Color : INTEGER (* Usual background color *);
-
- Menu_Text_Color : INTEGER (* Color for menu text *);
- Menu_Frame_Color : INTEGER (* Color for menu frame *);
-
- Text_Mode : INTEGER (* Text mode for all text *);
- Blinking_On : INTEGER (* >0 if blinking turned on *);
-
- (*----------------------------------------------------------------------*)
- (* VT100 emulation colors *)
- (*----------------------------------------------------------------------*)
-
- VT100_ForeGround_Color : INTEGER (* VT100 foreground color *);
- VT100_BackGround_Color : INTEGER (* VT100 background color *);
- VT100_Underline_Color : INTEGER (* VT100 foreground color *);
- VT100_Bold_Color : INTEGER (* VT100 background color *);
-
- (*----------------------------------------------------------------------*)
- (* Program Option Flags *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Local_Echo : BOOLEAN (* Local Echo ON/OFF *);
- BS_Char : CHAR (* CHAR to send when Back Space hit *);
- Ctrl_BS_Char : CHAR (* CHAR to send when CTRL BS hit *);
- Silent_Mode : BOOLEAN (* TRUE to suppress bells, music. *);
- Printer_On : BOOLEAN (* Echo to printer *);
- Capture_On : BOOLEAN (* Capture mode on *);
- Exact_Capture : BOOLEAN (* TRUE for exact capture mode *);
- Translate_On : BOOLEAN (* Translate mode on *);
- Ansi_Graphics_On : BOOLEAN (* If ansi graphics mode on *);
- Add_LF : BOOLEAN (* Add line feeds to incoming lines *);
- Play_Music_On : BOOLEAN (* Play music if found *);
- Pibterm_Done : BOOLEAN (* Finished running PibTerm *);
- Gossip_Mode_On : BOOLEAN (* Split-screen gossip mode *);
- Reset_Comm_Port : BOOLEAN (* TRUE to reset comm port *);
- Comm_Port_Changed : BOOLEAN (* TRUE if comm port number changed *);
- Host_Mode : BOOLEAN (* TRUE if PibTerm in host mode *);
- Last_Column_Hit : BOOLEAN (* TRUE if col 80 hit in display *);
- Auto_Wrap_Mode : BOOLEAN (* TRUE for autowrap on long lines *);
- Exploding_Menus : BOOLEAN (* TRUE to use exploding menus *);
- Review_On : BOOLEAN (* TRUE if review buffer used *);
- Script_File_Mode : BOOLEAN (* TRUE if currently exec'ing script *);
- CompuServe_B_On : BOOLEAN (* CompuServe B protocol in VT52 *);
- Mahoney_On : BOOLEAN (* Mahoney BBS codes allowed in VT52 *);
- When_Mode : BOOLEAN (* TRUE if WHEN string defined *);
- WaitString_Mode : BOOLEAN (* TRUE if WAITSTRING string defined *);
- Read_In_Script : BOOLEAN (* TRUE to read in script *);
- Really_Wait_String : BOOLEAN (* TRUE to really wait for string *);
- Write_Screen_Memory : BOOLEAN (* TRUE to write video memory direct *);
- Alter_Baud_Rate : BOOLEAN (* TRUE to get baud rate from modem *);
- Check_CTS : BOOLEAN (* TRUE to check clear-to-send line *);
- Check_DSR : BOOLEAN (* TRUE to check data-set-ready line *);
-
- (*----------------------------------------------------------------------*)
- (* Global files *)
- (*----------------------------------------------------------------------*)
-
- TYPE
- Text_File = TEXT [512] (* General text file *);
-
- VAR
- Config_File : Text_File (* Global configuration file *);
- Capture_File : Text_File (* Capture file *);
- Xfer_List_File : Text_File (* File transfer list file *);
- Command_File : Text_File (* Command file *);
- Script_File : Text_File (* Script file *);
-
- Capture_File_Name : FileStr (* Capture file name *);
-
- Home_Dir_Path : FileStr (* Home Directory Path for PibTerm *);
- Home_Dir : FileStr (* Home Directory for PibTerm *);
- Home_Drive : CHAR (* Home Drive Letter for PibTerm *);
-
- Screen_Dump_Name : FileStr (* Screen dump file name *);
- Script_File_Name : FileStr (* Script file name *);
-
- (*----------------------------------------------------------------------*)
- (* Review buffer *)
- (*----------------------------------------------------------------------*)
-
- TYPE
- Review_Buffer_Type = ARRAY[1..1] OF STRING[80];
- Review_Buffer_Ptr = ^Review_Buffer_Type;
-
- VAR
- Max_Review_Length : INTEGER (* Number of lines in review buffer *);
-
- (* Review buffer pointer *)
- Review_Buffer: Review_Buffer_Ptr;
-
- Review_Line : AnyStr (* Current line *);
- Review_Head : INTEGER (* Head of review buffer *);
- Review_Tail : INTEGER (* Tail of review buffer *);
-
- (*----------------------------------------------------------------------*)
- (* Incoming/Outgoing key definitions *)
- (*----------------------------------------------------------------------*)
-
- (* Keypad key strings *)
-
- Keypad_Keys : ARRAY[1..3] OF ARRAY[1..10] OF STRING[12];
-
- (* Maps input key to Keypad_Key *)
-
- Keypad_Key_Index : ARRAY[0..255] OF BYTE;
-
- (* Keypad key names *)
-
- Keypad_Key_Names : ARRAY[1..3] OF ARRAY[1..10] OF STRING[4];
-
- (* Function key definitions *)
-
- Function_Keys : ARRAY[1..4] OF ARRAY[1..10] OF KeyStr;
-
- Key_No : INTEGER (* Key number to execute *);
-
- FK_CR : CHAR (* Function key definition CR *);
- FK_Delay : CHAR (* Function key def. 1 second wait *);
- FK_Wait_For : CHAR (* Function key wait for next char *);
- FK_Ctrl_Mark : CHAR (* Marks next char as ctrl character *);
- FK_Script_Ch : CHAR (* Script to execute follows *);
- (* Incoming character translate table *)
- TrTab : ARRAY[CHAR] OF CHAR;
-
- (*----------------------------------------------------------------------*)
- (* Global communications variables *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Data_Bits : 5..8;
- Parity : CHAR;
- Stop_Bits : 0..2;
- Comm_Port : 1..2;
- Baud_Rate : 110..9600;
-
- (*----------------------------------------------------------------------*)
- (* Global variables for view file/directory/area codes *)
- (*----------------------------------------------------------------------*)
-
- VAR
- View_Count : INTEGER;
- View_Line : STRING[128];
- View_Done : BOOLEAN;
- View_Char : STRING[1];
- View_Y : INTEGER;
-
- (*----------------------------------------------------------------------*)
- (* Types and Variables for Terminal Emulation Facilities *)
- (*----------------------------------------------------------------------*)
-
- TYPE
- Terminal_Type = ( Dumb, VT52, Ansi, VT100, Gossip, HostMode, TV920,
- TEK4014, VT220 );
-
- VAR
- (* Type of terminal to emulate *)
- Terminal_To_Emulate : Terminal_Type;
-
- (* Saves previous term. type *)
- Saved_Gossip_Term : Terminal_Type;
-
-
- (*----------------------------------------------------------------------*)
- (* Global variables for phone directory handling *)
- (*----------------------------------------------------------------------*)
-
- CONST
- Max_Phone_Prefixes = 5;
- Max_Dial_Numbers = 5;
- Default_Phone_Number_Size = 200;
-
- (* STRUCTURED *) CONST
- Phone_Prefix_Chars : ARRAY[ 1 .. Max_Phone_Prefixes ] OF CHAR
- = ( '+', '-', '!', '@', '#' );
-
- TYPE
-
- Char_25 = PACKED ARRAY[ 1 .. 25 ] OF CHAR;
- Char_15 = PACKED ARRAY[ 1 .. 15 ] OF CHAR;
- Char_5 = PACKED ARRAY[ 1 .. 5 ] OF CHAR;
- Char_2 = PACKED ARRAY[ 1 .. 2 ] OF CHAR;
-
- String30 = STRING[30];
-
- (* Dialing file entry *)
- Phone_Number_Record = RECORD
- Phone_Name: Char_25;
- Phone_Number: Char_15;
- Phone_Baud: Char_5;
- Phone_Parity: CHAR;
- Phone_DataBits: CHAR;
- Phone_StopBits: CHAR;
- Phone_ENDer : Char_2;
- END;
-
- (* Dialing file *)
-
- Phone_File_Type = FILE OF Phone_Number_Record;
-
-
- VAR
- (* Phone directory file *)
- Phone_File : Phone_File_Type;
-
- (* Current phone entry data *)
- Phone_Entry_Data : Phone_Number_Record;
-
- (* Current phone record number *)
- Phone_Entry_Number : INTEGER;
- (* Current phone page number *)
- Phone_Entry_Page : INTEGER;
- (* File with phone prefixes *)
- Phone_Prefix_File : Text_File;
-
- (* Phone prefix numbers *)
-
- Phone_Prefix_Nos : ARRAY[ 1 .. Max_Phone_Prefixes ] OF ShortStr;
-
- Default_Prefix : CHAR (* Default prefix character *);
- Default_Postfix : CHAR (* Default postfix character *);
- Phone_Number : String30 (* Phone number to dial *);
- Prefix_Str : ShortStr (* Phone number prefix *);
- Postfix_Str : ShortStr (* Phone number postfix *);
-
- Modem_Init : ShortStr (* Modem initialization string *);
-
- Modem_Dial : ShortStr (* Modem dialing command *);
- Modem_Busy : ShortStr (* Modem return if line busy *);
- Modem_Connect : ShortStr (* Modem connect message *);
- Modem_No_Carrier : ShortStr (* Modem no carrier message *);
- Modem_Escape : ShortStr (* Modem escape command *);
- Modem_Escape_Time : INTEGER (* Time in mil. for escape *);
- Modem_Hang_Up : ShortStr (* Modem hangup command *);
- Modem_Time_Out : REAL (* Modem time out value *);
- Modem_Redial_Delay : REAL (* Modem redial delay *);
- Modem_Answer : ShortStr (* Modem answer phone *);
- Modem_Host_Set : ShortStr (* Modem host mode setup *);
- Modem_Command_Delay : INTEGER (* Ms between command chars *);
- Modem_Carrier_High : BOOLEAN (* TRUE if carrier line high *);
- Host_Auto_Baud : BOOLEAN (* Attempt auto speed detect *);
-
- (*----------------------------------------------------------------------*)
- (* Global variables for music playing *)
- (*----------------------------------------------------------------------*)
-
- VAR
- (* Current Octave for Note *)
- Note_Octave : INTEGER;
- (* Fraction of duration given to note *)
- Note_Fraction : REAL;
- (* Duration of note *)
- Note_Duration : INTEGER;
- (* Length of note *)
- Note_Length : REAL;
- (* Length of quarter note (principal beat) *)
- Note_Quarter : REAL;
-
- (*----------------------------------------------------------------------*)
- (* Global variables for file transfers *)
- (*----------------------------------------------------------------------*)
-
- CONST
- (* Special characters used in XMODEM *)
-
- SOH = $01; (* Start of XMODEM block *)
- STX = $02; (* Start of Ymodem block *)
- EOT = $04; (* End of XMODEM transmission *)
- ACK = $06; (* Acknowledge an XMODEM block *)
- NAK = $15; (* Refuse an XMODEM block *)
- SYN = $16; (* Start of Telink header *)
- CAN = $18; (* Cancel XMODEM transfer *)
-
- TYPE
- Sector_Type = ARRAY[ 1 .. 1026 ] OF BYTE;
- File_Handle_Buffer_Type = ARRAY[ 1 .. 2048 ] OF BYTE;
- File_Handle_Buffer_Ptr = ^File_Handle_Buffer_Type;
-
- VAR
- Sector_Size : INTEGER (* Size of Xmodem sector *);
-
- (* One sector of data *)
- Sector_Data : Sector_Type;
-
- Sector_Number : INTEGER (* Current sector number being sent *);
-
- Max_Write_Buffer : INTEGER (* Download buffer size *);
-
-
- (* Transfer Declarations *)
- TYPE
-
- Transfer_Type = ( Ascii, Xmodem_Chk, Xmodem_CRC, Kermit, Telink,
- Modem7_Chk, Modem7_CRC, Ymodem, Ymodem_Batch, None );
-
- Transfer_Str = STRING[255];
-
- CONST
- Max_Transfer_Types = 10;
-
- (* STRUCTURED *) CONST
- Transfers : ARRAY[ 1 .. Max_Transfer_Types ] OF Transfer_Type
- = ( Ascii, Xmodem_Chk, Xmodem_Crc, Kermit, Telink,
- Modem7_Chk, Modem7_CRC, Ymodem, Ymodem_Batch, None );
-
- (* Files for transfers *)
- VAR
-
- AFile : TEXT [4096] (* Ascii File uploaded/downloaded *);
- XFile_Handle : INTEGER (* Xmodem File uploaded/downloaded *);
- FileName : STRING[64] (* Name of file *);
-
-
- (* Timing/Delay Constants and Variables *)
- CONST
-
- One_Second = 1 (* One second *);
- Two_Seconds = 2 (* Two seconds *);
- Five_Seconds = 5 (* Five seconds *);
- Ten_Seconds = 10 (* Ten seconds *);
- Twenty_Seconds = 20 (* Twenty seconds *);
- Sixty_Seconds = 60 (* Sixty seconds *);
- Trans_Time_Val = 1800.0 (* Fudge factor for transfer times *);
-
- VAR
-
- Char_Delay : INTEGER (* Character delay for Ascii trans. *);
- Line_Delay : INTEGER (* Line delay for Ascii transfers *);
- Pacing_Char : CHAR (* Pacing character for uploads *);
- CR_LF_String: STRING[2] (* CR or CR+LF to end ASCII lines *);
-
- (* Save/restore transmission params during XMODEM *)
-
- VAR
- Xmodem_Bits_Save: INTEGER (* Save # bits per character *);
- Xmodem_Parity_Save: CHAR (* Save parity *);
- Xmodem_Stop_Save: INTEGER (* Save stop bits *);
-
- VAR (* Default transfer type *)
- Default_Transfer_Type : Transfer_Type;
-
- VAR
- Stop_Receive : BOOLEAN (* TRUE to cancel receiving of file. *);
- Stop_Send : BOOLEAN (* TRUE to cancel sending of file. *);
- Use_Time_Sent : BOOLEAN (* TRUE to stamp file with received *)
- (* time and date. *);
- Null_File_Name : BOOLEAN (* TRUE if null file name in Ymodem *);
- Ascii_Use_CtrlZ : BOOLEAN (* TRUE if CtrlZ used as EOF marker *);
- Ascii_Show_Text : BOOLEAN (* TRUE to display text during trans.*);
- Ascii_Send_Blank: BOOLEAN (* TRUE to send empty lines as blank *);
- Display_Status : BOOLEAN (* TRUE to display transfer status *);
-
- VAR
- GMT_Difference: INTEGER (* Difference in hours between local *)
- (* time and Greenwich mean time *);
- VAR
- Transfer_Bells: INTEGER (* Number of bells after transfer *);
-
- (*----------------------------------------------------------------------*)
- (* Definitions for Kermit protocol transfers *)
- (*----------------------------------------------------------------------*)
-
- TYPE
-
- Kermit_Packet_String = STRING[150];
-
- Kermit_State_Vars = ( Send_Init, Send_File_Header, Send_File,
- Send_EOF, Send_Break, Receive_Init,
- Receive_Header, Receive_File, Send_Bye,
- Get_File );
-
- Kermit_File_Param = ( Kermit_Ascii, Kermit_Binary, Kermit_None );
-
- Kermit_Packet_Param = ( Break_Pack, Data_Pack, Error_Pack,
- Header_Pack, NAK_Pack, Send_Pack, Reserved_Pack,
- ACK_Pack, End_Pack, Unknown );
-
- Kermit_File_Modes = ( Read_Open, Write_Open );
-
-
- CONST
- Kermit_Init_Packet_Size = 94;
-
- VAR
- (* Type of file (Ascii, Binary) *)
-
- Kermit_File_Type_Var : Kermit_File_Param;
-
- (* Type of current Kermit packet *)
-
- Kermit_Packet_Type : Kermit_Packet_Param;
-
- (* Current state of Kermit transfer *)
-
- Kermit_State : Kermit_State_Vars;
-
- (* If remote kermit in server mode *)
- Kermit_Remote_Server : BOOLEAN;
-
- Kermit_Packet_Size : INTEGER (* Size of current packet *);
- Kermit_Timeout : INTEGER (* Timeout value in seconds *);
- His_TimeOut : INTEGER (* Timeout desired by remote *);
- Kermit_Npad : INTEGER (* Number of padding characters *);
- Kermit_EOL : CHAR (* End of line character *);
- Kermit_Header_Char : CHAR (* Block header character *);
-
- Kermit_Pad_Char : CHAR (* Padding character *);
- Kermit_Quote_Char : CHAR (* Control-quote character *);
- Kermit_Quote_8_Char : CHAR (* 8-bit quoting character *);
- Kermit_Chk_Type : CHAR (* Block-check type *);
- Kermit_Repeat_Char : CHAR (* Repeat character *);
-
- (* Packet buffer area *)
-
- Packet_Buffer : Kermit_Packet_String;
-
- (* Complete packet to send *)
-
- Packet_Buffer_Data : Kermit_Packet_String;
-
- (* Complete packet received *)
-
- Rec_Packet : Kermit_Packet_String;
-
- Packet_OK : BOOLEAN (* TRUE if packet OK *);
- Ack_OK : BOOLEAN (* TRUE if packet ACK'd *);
- Open_OK : BOOLEAN (* TRUE if file to transfer opened OK *);
- File_Done : BOOLEAN (* TRUE if file being sent done *);
- Kermit_Abort : BOOLEAN (* TRUE if keyboard entry aborts transfer *);
- Kermit_Retry : BOOLEAN (* TRUE to retry current packet *);
-
- Packet_Num : INTEGER (* Packet number being sent *);
- Rec_Packet_Num : INTEGER (* Received packet number *);
- Packets_Sent : INTEGER (* Number of packets sent *);
- Packets_Received : INTEGER (* Number of packets received *);
- Packets_Bad : INTEGER (* Number of errors in transfer *);
-
- File_Open : BOOLEAN (* TRUE if file being transferred is open *);
-
- (* Received file data *)
-
- Received_Data : Kermit_Packet_String;
-
- Quoting : BOOLEAN (* TRUE if 8th-bit quoting in effect *);
- Repeating : BOOLEAN (* TRUE if repeating/compression in effect *);
- Sending_File : BOOLEAN (* TRUE if uploading, FALSE if downloading *);
- Logging_Out_Server : BOOLEAN (* TRUE if logging out remote server *);
-
- My_Pad_Char : CHAR (* Default pad character *);
- His_Quote_Char : CHAR (* Remote kermit's quote character *);
- His_Quote_8_Char : CHAR (* Remote kermit's 8th-bit quote character *);
- His_Chk_Type : CHAR (* Remote kermit's block check type *);
-
- My_Pad_Num : INTEGER (* Default number of padding characters *);
- Send_EOL : INTEGER (* Send CR first time *);
-
- File_Records : REAL (* Number of bytes in disk file *);
- FilePointer : INTEGER (* Where we are in the record *);
- Buffer_Num : REAL (* How many characters read/written *);
- Kermit_Delay_Time : INTEGER (* Time to wait before send in host mode *);
- Receive_Done : BOOLEAN (* TRUE if file reception complete *);
- Kermit_MaxTry : INTEGER (* Maximum number of retries allowed *);
-
- (* TRUE to turn off remote Kermit server *)
-
- Finish_Kermit_Server : BOOLEAN;
-
- (* TRUE if Kermit in debug mode *)
-
- Kermit_Debug : BOOLEAN;
-
- (*----------------------------------------------------------------------*)
- (* Global script file variables *)
- (*----------------------------------------------------------------------*)
-
- CONST
- Max_Script_File_Commands = 45;
-
- (* STRUCTURED *) CONST
- (* Valid command names for scripts *)
-
- Script_File_Command_Names : ARRAY[1..Max_Script_File_Commands] OF STRING[8]
- = ( 'ADDLF', 'BREAK', 'CAPTURE', 'CASE',
- 'CLEAR', 'DELAY', 'DIAL',
- 'DOS', 'ECHO', 'ELSE', 'ENDCASE',
- 'ENDIF',
- 'ENDWHILE', 'EXIT', 'FILE', 'GOTO',
- 'HANGUP',
- 'HOST', 'IF', 'INPUT', 'KEY',
- 'KEYDEF', 'KEYSEND',
- 'LABEL', 'LOG', 'MESSAGE', 'MUTE',
- 'OTHERWIS',
- 'PARAM', 'RECEIVE', 'REDIAL', 'REPEAT',
- 'RESET', 'RINPUT', 'SCREENDUM','SEND' ,
- 'STEXT', 'SUSPEND', 'TEXT', 'TRANSLAT',
- 'UNTIL',
- 'WAIT', 'WAITSTRI', 'WHEN', 'WHILE' );
-
- (* Corresponding command types *)
-
- Script_File_Commands : ARRAY[1..Max_Script_File_Commands] OF
- PibTerm_Command_Type =
- ( AddLFSy, BreakSy, CaptureSy, CaseSy,
- ClearSy, DelaySy, DialSy, DosSy,
- EchoSy, ElseSy, EndCaseSy, EndIfSy,
- EndWhileSy, ExitSy, FileSy, GoToSy,
- HangUpSy,
- HostSy, IfLocStrSy, InputSy, KeySy,
- KeyDefSy, KeySendSy,
- LabelSy, LogSy, MessageSy, MuteSy,
- OtherSy, ParamSy, ReceiveSy, RedialSy,
- RepeatSy, ResetSy, RInputSy, SDumpSy,
- SendSy, STextSy, SuspendSy, TextSy,
- TranslateSy, UntilSy, WaitSy, WaitStrSy, WhenSy,
- WhileSy );
-
- (* Script conversion table *)
-
- PibTerm_Command_Table_2 : ARRAY[0..No_Of_PibTerm_Commands_Minus_One]
- OF PibTerm_Command_Type
- = ( AddLFSy, AreaCodeSy, BreakSy, CaptureSy,
- CaseSy, ClearSy, DelaySy, DialSy,
- DosSy, EchoSy, EditSy, ElseSy,
- EndCaseSy, EndIfSy, EndWhileSy, ExitSy,
- FastCSy, FileSy, GossipSy, GoToSy,
- HangUpSy, HostSy, IfConSy, IfFoundSy,
- IfLocStrSy, IfRemStrSy, InfoSy, InputSy,
- KeyDefSy, KeySendSy,
- KeySy, LabelSy, LogSy, MessageSy,
- MuteSy, OtherSy, ParamSy, QuitSy,
- ReceiveSy, ReDialSy, RepeatSy, ResetSy,
- RInputSy, SDumpSy, SendSy, STextSy,
- SuspendSy, TextSy, TimersSy, TranslateSy,
- UntilSy, ViewSy, WaitSy, WaitStrSy,
- WhenSy, WhileSy,
- Bad_Command, Null_Command
- );
-
- TYPE
- (* Generic buffer type to hold script *)
-
- Script_Buffer_Type = ARRAY[1..1] OF BYTE;
-
- (* For pointing to start of script *)
-
- Script_Buffer_Ptr = ^Script_Buffer_Type;
-
- VAR
- (* WHEN text to wait for *)
- Script_When_Text : AnyStr;
-
- (* Response text for WHEN *)
- Script_When_Reply_Text : AnyStr;
-
- (* Current input for WHEN checking *)
- Script_When_Save : AnyStr;
-
- (* WAITSTRING text to wait for *)
- Script_Wait_Text : AnyStr;
-
- (* Response text for WAITSTRING *)
- Script_Wait_Reply_Text : AnyStr;
-
- (* Current input for WAITSTRING checking *)
- Script_Wait_Save : AnyStr;
-
- (* Time to wait for input string *)
- Script_Wait_Time : INTEGER;
-
- (* Starting time of day for wait *)
- Script_Wait_Start : REAL;
-
- (* Where to go to if wait string fails *)
- Script_Wait_Failure : INTEGER;
-
- (* Wait string appeared *)
- Script_Wait_Found : BOOLEAN;
-
- (* Size of script buffer *)
-
- Script_Buffer_Size : INTEGER;
-
- (* Pointer to compiled script text *)
-
- Script_Buffer : Script_Buffer_Ptr;
-
- (* Current position in script buffer *)
-
- Script_Buffer_Pos : INTEGER;
-
- (* Script integer values *)
-
- Script_Integer_1 : INTEGER;
- Script_Integer_2 : INTEGER;
- Script_Integer_3 : INTEGER;
-
- (* Script text values *)
-
- Script_String : AnyStr;
- Script_String_2 : AnyStr;
-
- (* Reply to Script INPUT prompt *)
- Script_Reply : AnyStr;
-
- (* Reply was OK *)
- Script_Reply_Found : BOOLEAN;
-
- (* Script suspend time period *)
- Script_Suspend_Time : REAL;
-
- (* Script suspend starting time *)
- Script_Suspend_Start : REAL;
-
- (* Reply to Script RINPUT prompt *)
- Script_Remote_Reply : AnyStr;
-
- (* Reply was OK *)
- Script_Remote_Reply_OK : BOOLEAN;
-
-
- (*----------------------------------------------------------------------*)
- (* Global error return from DOS *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Ierr : INTEGER (* DOS return error *);
-
- (*----------------------------------------------------------------------*)
- (* Global screen positioning for autodownloads *)
- (*----------------------------------------------------------------------*)
-
- VAR
- NewX : INTEGER;
- OldX : INTEGER;
- NewY : INTEGER;
- OldY : INTEGER;
-
- (*----------------------------------------------------------------------*)
- (* Session timers *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Session_Start_Time: REAL (* Starting time of entire session *);
- Dialing_Start_Time: REAL (* Starting time current dialing *);
-
- (*----------------------------------------------------------------------*)
- (* PibTerm Command Key Definitions *)
- (*----------------------------------------------------------------------*)
-
- CONST
- Alt_A = 30; Alt_J = 36; Alt_S = 31;
- Alt_B = 48; Alt_K = 37; Alt_T = 20;
- Alt_C = 46; Alt_L = 38; Alt_U = 22;
- Alt_D = 32; Alt_M = 50; Alt_V = 47;
- Alt_E = 18; Alt_N = 49; Alt_W = 17;
- Alt_F = 33; Alt_O = 24; Alt_X = 45;
- Alt_G = 34; Alt_P = 25; Alt_Y = 21;
- Alt_H = 35; Alt_Q = 16; Alt_Z = 44;
- Alt_I = 23; Alt_R = 19; Alt_1 = 120;
-
- Shift_Tab = 15;
-
- F1 = 59; Alt_F1 = 104;
- F2 = 60; Alt_F2 = 105;
- F10 = 68; Alt_F10 = 113;
- Shift_F1 = 84; Ctrl_F1 = 94;
- Shift_F10 = 93; Ctrl_F10 = 103;
-
- U_Arrow = 72; Alt_U_Arrow = 175; Ctrl_U_Arrow = 160;
- D_Arrow = 80; Alt_D_Arrow = 183; Ctrl_D_Arrow = 164;
- L_Arrow = 75; Alt_L_Arrow = 178; Ctrl_L_Arrow = 115;
- R_Arrow = 77; Alt_R_Arrow = 180; Ctrl_R_Arrow = 116;
-
- Home = 71; Alt_Home = 174;
- End_Key = 79; Alt_End_Key = 182; Ctrl_End_Key = 117;
- PgUp = 73; Alt_PgUp = 176; Ctrl_PgUp = 132;
- PgDn = 81; Alt_PgDn = 184; Ctrl_PgDn = 118;
- Ins_Key = 82; Alt_Ins_Key = 185; Ctrl_Ins_Key = 165;
- Del_Key = 83; Alt_Del_Key = 186; Ctrl_Del_Key = 166;
-
- (*----------------------------------------------------------------------*)
- (* --- Included procedures for PibTerm --- *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Display_Character( Ch : CHAR );
- FORWARD;
-
- PROCEDURE Process_Command( VAR Ch : CHAR;
- Use_Ch : BOOLEAN;
- VAR Command : PibTerm_Command_Type );
- FORWARD;
-
- PROCEDURE Execute_Command( VAR Command : Pibterm_Command_Type;
- VAR Done : BOOLEAN;
- Use_Script : BOOLEAN );
- FORWARD;
-
- (*$IINT24.PAS *)
- (*$IMINMAX.PAS *)
- (*$IYESNO.PAS *)
- (*$IDUPL.PAS *)
- (*$IUPPERCAS.PAS *)
- (*$ICOPYSTOA.PAS *)
- (*$IMAXBLOCK.PAS *)
- (*$IREADCTRL.PAS *)
- (*$IWRITCTRL.PAS *)
- (*$IPIBTIMER.PAS *)
- (*$IPIBASYN1.PAS *)
- (*$IPIBASYN2.PAS *)
- (*$IPIBSCREN.PAS *)
- (*$ICLEARWIN.PAS *)
- (*$IPIBMENUS.PAS *)
- (*$IPIBDIR.PAS *)
- (*$IPIBFHIO.PAS *)
- (*$ITRIM.PAS *)
- (*$ILTRIM.PAS *)
- (*$ISENDMODE.PAS *)
- (*$IVIEWPMPT.PAS *)
- (*$IPIBCRC.PAS *)
- (*$IHANGUP.PAS *)
- (*$ISCANXFER.PAS *)
- (*$IERRORHAN.PAS *)
- (*$ICAPTUREC.PAS *)
- (*$IWRITELNE.PAS *)
- (*$IINITOVLY.PAS *)
-
- (*----------------------------------------------------------------------*)
- (* First overlay segment starts here. *)
- (*----------------------------------------------------------------------*)
-
- (*$ISETTRTAB.PAS *)
- (*$ISETINPTK.PAS *)
- (*$IDISPHELP.PAS *)
- (*$IPIBDIALA.PAS *)
- (*$IPIBDIALB.PAS *)
- (*$IPIBFMANI.PAS *)
-
- (*-------------------------- Upload procedures -------------------------*)
-
- (*$IPIBUPLOD.PAS *)
- (*$IGETUPLOA.PAS *)
- (* Xmodem family *)
- (*$IDOXMODU1.PAS *)
- (*$ISENDXMOD.PAS *)
- (*$ISENDMDM7.PAS *)
- (*$ISENDYMOD.PAS *)
- (*$IDOXMODU2.PAS *)
- (* Ascii *)
- (*$ISENDASCI.PAS *)
- (* Kermit *)
- (*$ISENDKER1.PAS *)
- (*$IKINIT.PAS *)
- (*$IKERMCRC.PAS *)
- (*$IKDISPLAY.PAS *)
- (*$IADJUSTFN.PAS *)
- (*$IKOPEN.PAS *)
- (*$IKREC1.PAS *)
- (*$IKSEND1.PAS *)
- (*$ISENDKER2.PAS *)
- (*$IPIBUPLOB.PAS *)
-
- (*-------------------------End Upload procedures -----------------------*)
-
- (*------------------------ Download procedures -------------------------*)
-
- (*$IPIBDWLOD.PAS *)
- (*$IGETDOWNL.PAS *)
- (* Xmodem family *)
- (*$IDOXMODD1.PAS *)
- (*$IRECEIVEX.PAS *)
- (*$IRECEIVEM.PAS *)
- (*$IRECEIVEY.PAS *)
- (*$IDOXMODD2.PAS *)
- (* Ascii *)
- (*$IRECEIVEA.PAS *)
- (* Kermit *)
- (*$IRECEIVK1.PAS *)
- (*$IKINIT.PAS *)
- (*$IKERMCRC.PAS *)
- (*$IKDISPLAY.PAS *)
- (*$IKFIXFNAM.PAS *)
- (*$IADJUSTFN.PAS *)
- (*$IKOPEN.PAS *)
- (*$IKREC1.PAS *)
- (*$IKSEND1.PAS *)
- (*$IRECEIVK2.PAS *)
- (*$IPIBDWLOC.PAS *)
-
- (*-----------------------End Download procedures -----------------------*)
-
- (*-----------------------CompuServe B Protocol--------------------------*)
-
- (*$IDOCOMPUS.PAS *)
-
- (*-----------------------End CompuServe B Protocol----------------------*)
-
- (*$IEDITALIN.PAS *)
- (*$IGETAREAC.PAS *)
- (*$ISETPARMA.PAS *)
- (*$ISETPARMB.PAS *)
- (*$ISETPARMC.PAS *)
- (*$IREVIEWCA.PAS *)
- (*$IDISPLAYT.PAS *)
- (*$IDOSCDUMP.PAS *)
- (*$IGETCAPTU.PAS *)
- (*$IFASTCHNG.PAS *)
- (*$IDOSJUMP.PAS *)
- (*$IPROCESSS.PAS *)
-
- (*----------------------------------------------------------------------*)
- (* Dummy constant to break up overlay. *)
- (*----------------------------------------------------------------------*)
-
- CONST
- Dummy_Const = 99;
-
- (*---------------------Primary character input/output handling----------*)
-
- (*$ISENDFUNK.PAS *)
- (*$ICHECKWAI.PAS *)
- (*$IDISPLAYC.PAS *)
- (*$ITOGGLEOP.PAS *)
- (*$IPROCESSC.PAS *)
- (*$IGETSCRIP.PAS *)
- (*$IEXECUTEC.PAS *)
-
- (*----------------------------------------------------------------------*)
- (* Second overlay segment starts here. *)
- (*----------------------------------------------------------------------*)
-
- (*---------------------Ansi/VT100 Terminal Emulator --------------------*)
-
- (*$IPIBANSIA.PAS *)
- (*$IPIBANSIB.PAS *)
-
- (*---------------------------VT52 Terminal Emulator --------------------*)
-
- (*$IPIBVT52.PAS *)
-
- (*--------------------------------Host Mode ----------------------------*)
-
- (*$IPIBHOSTA.PAS *)
- (*$IPIBHOSTB.PAS *)
- (*$IPIBHOSTC.PAS *)
-
- (*--------------------------Dumb Terminal Mode -------------------------*)
-
- (*$IPIBDUMBT.PAS *)
-
- (*--------------------------Gossip Mode---------------------------------*)
-
- (*$IPIBGOSSI.PAS *)
-
- (*--------------------------VT220 Terminal Emulator --------------------*)
-
- (*$IPIBVT220.PAS *)
-
- (*--------------------------TV920 Terminal Emulator --------------------*)
-
- (*$IPIBTV920.PAS *)
-
- (*-----------------------TEK 4014 Terminal Emulator --------------------*)
-
- (*$IPIBT4014.PAS *)
-
- (*----------------------PibTerm Initialization--------------------------*)
-
- (*$IINITTERM.PAS *)
-
- (* ------------------------------------------------------------------------ *)
- (* PibTerm --- Main Program *)
- (* ------------------------------------------------------------------------ *)
-
- BEGIN (* PibTerm *)
- (* Get overlay directory *)
- InitOvly;
- (* Initialize PibTerm *)
- InitTerm;
- (* Program finished flag *)
- PibTerm_Done := FALSE;
-
- REPEAT
- (* BEGIN Terminal Emulation *)
- CASE Terminal_To_Emulate Of
- VT52: Emulate_VT52;
- Dumb: Emulate_Dumb_Terminal;
- Ansi: Emulate_Ansi( FALSE );
- VT100: Emulate_Ansi( TRUE );
- Gossip: Emulate_Gossip;
- HostMode: Emulate_Host;
- TV920: Emulate_TV920;
- TEK4014: Emulate_TEK4014;
- VT220: Emulate_VT220;
- END (* CASE *);
-
- UNTIL ( PibTerm_Done );
- (* Close down serial port *)
- Async_Close;
- (* Close capture file *)
- IF Capture_On THEN
- (*$I-*)
- CLOSE( Capture_File );
- (*$I+*)
- (* Remove scrolling buffer *)
- IF Review_Buffer <> NIL THEN
- FREEMEM( Review_Buffer , 81 * Max_Review_Length );
-
- (* Remove Interrupt 24 trap *)
- Int24OFF;
- (* Clear screen *)
- ClrScr;
-
- END (* PibTerm *).